audio_form object
This method will set the position of the cursor in a listbox.
bool set_list_position(int control_id, int new_position)
Parameters:
control_id
The control ID of the listbox.
new_position
The position in the listbox to highlight. -1 indicates that no item is to be highlighted.
Return value:
true on success, false on failure.
Remarks:
This is useful for automatically filling in information into a form.
Please note that the position does not need to be manually set when monitoring for input, since the audio_form class changes the position automatically when different items are selected.
Example:
// Make a simple form with a few buttons and a listbox.
#include "form.bgt"
audio_form form;
void main()
{
form.create_window("Example Form", true);
int list=form.create_list("&People", 0);
form.add_list_item(list, "Joseph", -1);
form.add_list_item(list, "Samuel", -1);
form.add_list_item(list, "Percival", 1);
form.add_list_item(list, "William", -1);
form.add_list_item(list, "Edward", 0);
form.set_list_position(list, 2);
int ok=form.create_button("OK");
int cancel=form.create_button("E&xit");
while(true)
{
form.monitor();
wait(5);
if(form.is_pressed(ok))
{
alert("Information", "The listbox cursor is at position "+form.get_list_position(list));
exit();
}
if(form.is_pressed(cancel))
{
exit();
}
if((key_down(KEY_LMENU))&&(key_pressed(KEY_F4)))
{
exit();
}
}
}